package org.achartengine.internal.chart;

import android.graphics.Canvas;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import org.achartengine.internal.renderer.XYMultipleSeriesRenderer;

/* loaded from: classes2.dex */
public class f extends k {
    private static final int a = 30;
    public static final String c = "Line";
    private static final long serialVersionUID = 1;
    private i b;
    private float[] h;
    private int i;

    @Override // org.achartengine.internal.chart.a
    public int a(int i) {
        return 30;
    }

    @Override // org.achartengine.internal.chart.k
    public String c() {
        return "Line";
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public f() {
        this.h = new float[0];
        this.i = -1;
    }

    public f(org.achartengine.internal.model.g gVar, XYMultipleSeriesRenderer xYMultipleSeriesRenderer) {
        super(gVar, xYMultipleSeriesRenderer);
        this.h = new float[0];
        this.i = -1;
        this.b = new i(gVar, xYMultipleSeriesRenderer);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // org.achartengine.internal.chart.k
    public void a(org.achartengine.internal.model.g gVar, XYMultipleSeriesRenderer xYMultipleSeriesRenderer) {
        super.a(gVar, xYMultipleSeriesRenderer);
        this.b = new i(gVar, xYMultipleSeriesRenderer);
    }

    @Override // org.achartengine.internal.chart.k
    public void a(Canvas canvas, Paint paint, float[] fArr, org.achartengine.internal.renderer.b bVar, float f, int i) {
        float[] fArr2 = new float[fArr.length];
        this.h = fArr2;
        System.arraycopy(fArr, 0, fArr2, 0, fArr.length);
        int length = fArr.length;
        org.achartengine.internal.renderer.c cVar = (org.achartengine.internal.renderer.c) bVar;
        float strokeWidth = paint.getStrokeWidth();
        paint.setStrokeWidth(cVar.g());
        if (cVar.c()) {
            paint.setColor(cVar.e());
            float[] fArr3 = new float[fArr.length + 4];
            System.arraycopy(fArr, 0, fArr3, 0, length);
            fArr3[0] = fArr[0] + 1.0f;
            fArr3[length] = fArr3[length - 2];
            int i2 = length + 1;
            fArr3[i2] = f;
            fArr3[length + 2] = fArr3[0];
            fArr3[length + 3] = fArr3[i2];
            paint.setStyle(Paint.Style.FILL);
            a(canvas, fArr3, paint, true);
        }
        paint.setColor(bVar.b());
        paint.setPathEffect(new DashPathEffect(new float[]{15.0f, 5.0f, 8.0f, 5.0f}, 5.0f));
        paint.setStyle(Paint.Style.STROKE);
        a(canvas, fArr, paint, false);
        paint.setPathEffect(null);
        paint.setStrokeWidth(strokeWidth);
    }

    @Override // org.achartengine.internal.chart.a
    public void a(Canvas canvas, org.achartengine.internal.renderer.b bVar, float f, float f2, int i, Paint paint) {
        canvas.drawLine(f, f2, f + 30.0f, f2, paint);
        if (a(bVar)) {
            this.b.a(canvas, bVar, f + 5.0f, f2, i, paint);
        }
    }

    @Override // org.achartengine.internal.chart.k
    public boolean a(org.achartengine.internal.renderer.b bVar) {
        return ((org.achartengine.internal.renderer.c) bVar).f() != PointStyle.POINT;
    }

    @Override // org.achartengine.internal.chart.k
    public i a_() {
        return this.b;
    }

    @Override // org.achartengine.internal.chart.a
    /* renamed from: b */
    public org.achartengine.internal.model.b a(float f, float f2) {
        int i = 0;
        org.achartengine.internal.model.h b = this.d.b(0);
        this.i = -1;
        double d = 100.0d;
        org.achartengine.internal.model.b bVar = null;
        while (true) {
            float[] fArr = this.h;
            if (i >= fArr.length) {
                return bVar;
            }
            float f3 = f - fArr[i];
            float f4 = f2 - fArr[i + 1];
            double sqrt = Math.sqrt((f3 * f3) + (f4 * f4 * f4));
            if (sqrt < d) {
                int i2 = i / 2;
                this.i = i2;
                bVar = new org.achartengine.internal.model.b(this.e.a(Double.valueOf(b.b(i2))), Double.valueOf(b.c(i2)));
                d = sqrt;
            }
            i += 2;
        }
    }
}
